/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package com.stip.server.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author BlueBerry
 */
@Entity
@Table(name = "users_main")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UsersMain.findAll", query = "SELECT u FROM UsersMain u"),
    @NamedQuery(name = "UsersMain.findByUid", query = "SELECT u FROM UsersMain u WHERE u.uid = :uid"),
    @NamedQuery(name = "UsersMain.findByPassword", query = "SELECT u FROM UsersMain u WHERE u.password = :password")})
public class UsersMain implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "uid")
    private String uid;
    @Size(max = 16)
    @Column(name = "password")
    private String password;
    @OneToMany(mappedBy = "userId")
    private List<UserAct> userActList;
    @OneToMany(mappedBy = "uid")
    private List<Admin> adminList;
    @JoinColumn(name = "uid", referencedColumnName = "uid", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private UserHub userHub;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "usersMain")
    private UsersInfo usersInfo;

    public UsersMain() {
    }

    public UsersMain(String uid) {
        this.uid = uid;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @XmlTransient
    public List<UserAct> getUserActList() {
        return userActList;
    }

    public void setUserActList(List<UserAct> userActList) {
        this.userActList = userActList;
    }

    @XmlTransient
    public List<Admin> getAdminList() {
        return adminList;
    }

    public void setAdminList(List<Admin> adminList) {
        this.adminList = adminList;
    }

    public UserHub getUserHub() {
        return userHub;
    }

    public void setUserHub(UserHub userHub) {
        this.userHub = userHub;
    }

    public UsersInfo getUsersInfo() {
        return usersInfo;
    }

    public void setUsersInfo(UsersInfo usersInfo) {
        this.usersInfo = usersInfo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uid != null ? uid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsersMain)) {
            return false;
        }
        UsersMain other = (UsersMain) object;
        if ((this.uid == null && other.uid != null) || (this.uid != null && !this.uid.equals(other.uid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.stip.server.entities.UsersMain[ uid=" + uid + " ]";
    }
    
}
